<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>n8n CRM - 房产客户关系管理系统</title>
    <!-- 防止浏览器扩展干扰 -->
    <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' data: blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data: https:; connect-src 'self' ws: wss: http: https:;">
    <!-- 清理外部资源预加载 -->
    <script>
      // 清理可能的外部资源预加载
      document.addEventListener('DOMContentLoaded', function() {
        // 移除可能的外部预加载链接
        const externalLinks = document.querySelectorAll('link[rel="preload"]');
        externalLinks.forEach(link => {
          const href = link.getAttribute('href');
          if (href && (href.includes('ydlunacommon-cdn.nosdn.127.net') || 
                       href.includes('netease') || 
                       href.includes('163.com'))) {
            link.remove();
            console.log('已移除外部预加载资源:', href);
          }
        });
      });
    </script>
  </head>
  <body>
    <div id="app"></div>
    <script type="module" src="/src/main.ts"></script>
    <!-- 错误处理脚本 -->
    <script>
      // 捕获并处理扩展相关错误
      window.addEventListener('error', function(e) {
        if (e.message && (e.message.includes('content.js') || 
                         e.message.includes('undefined') ||
                         e.message.includes('res'))) {
          console.warn('浏览器扩展错误已忽略:', e.message);
          e.preventDefault();
          return false;
        }
      });
      
      // 处理未捕获的Promise错误
      window.addEventListener('unhandledrejection', function(e) {
        if (e.reason && e.reason.message && 
            (e.reason.message.includes('content.js') || 
             e.reason.message.includes('runtime.lastError'))) {
          console.warn('扩展Promise错误已忽略:', e.reason.message);
          e.preventDefault();
          return false;
        }
      });
      
      // 处理扩展消息端口错误
      if (typeof chrome !== 'undefined' && chrome.runtime) {
        try {
          chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
            // 确保响应处理
            if (sendResponse) {
              sendResponse({status: 'ok'});
            }
            return true;
          });
        } catch (e) {
          console.warn('扩展消息处理已禁用:', e.message);
        }
      }
      
      // 清理资源预加载警告
      const originalConsoleWarn = console.warn;
      console.warn = function(...args) {
        const message = args.join(' ');
        if (message.includes('preloaded using link preload but not used') ||
            message.includes('ydlunacommon-cdn.nosdn.127.net')) {
          // 忽略外部资源预加载警告
          return;
        }
        originalConsoleWarn.apply(console, args);
      };
    </script>
  </body>
</html>
